﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cachkkhac.aspx.cs" Inherits="Telerik.GridExamplesCSharp.DataEditing.AllEditableColumns.cachkkhac" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
 <title></title>
    <!-- custom head section -->
    <style type="text/css">
        .MyImageButton
        {
           cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: #0066cc;
        }
        </style>
    <!-- end of custom head section -->
</head>
<body class="BODY">
    <form id="mainForm" runat="server">
       
       <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        
       
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False"  DataSourceID="SessionDataSource1" OnItemUpdated="RadGrid1_ItemUpdated"
            OnItemDeleted="RadGrid1_ItemDeleted" 
           OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound" 
           AllowSorting="True" CellSpacing="0">
            <PagerStyle Mode="NextPrevAndNumeric" />


            <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="MaAdmin"
                 DataSourceID="SessionDataSource1" HorizontalAlign="NotSet" 
                AutoGenerateColumns="False">
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                 <Columns>
                
                     <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="MaAdmin" HeaderText="MaAdmin" SortExpression="MaAdmin"
                        UniqueName="MaAdmin" DataType="System.Int32" 
                        ReadOnly="True">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TenAdmin" HeaderText="TenAdmin"
                        SortExpression="TenAdmin" UniqueName="TenAdmin" >
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Pass" 
                        HeaderText="Pass" 
                        SortExpression="Pass" UniqueName="Pass">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Email" 
                        HeaderText="Email" 
                        SortExpression="Email" UniqueName="Email">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Dienthoai" 
                        HeaderText="Dienthoai" 
                        SortExpression="Dienthoai" UniqueName="Dienthoai">
                    </telerik:GridBoundColumn>
                    
                    <telerik:GridButtonColumn ConfirmText="Delete this Admin?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings ColumnNumber="2" CaptionDataField="TenAdmin" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Product">
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
        
        
        <asp:SqlDataSource ID="SessionDataSource1" runat="server" 
           ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" ProviderName="System.Data.SqlClient"
           SelectCommand="SELECT [MaAdmin], [TenAdmin], [Pass], [Email], [Dienthoai] FROM [Admin]"
            DeleteCommand="DELETE FROM [Admin] WHERE [MaAdmin] = @original_MaAdmin" 
            InsertCommand="INSERT INTO Admin(TenAdmin, Pass, Email,Dienthoai) VALUES (@TenAdmin,@Pass,@Email,@Dienthoai)"
            UpdateCommand="UPDATE [Admin] SET [TenAdmin] = @TenAdmin, [Pass] = @Pass, [Email] = @Email, [Dienthoai] = @Dienthoai WHERE [MaAdmin] = @original_MaAdmin AND [TenAdmin] = @original_TenAdmin AND [Pass] = @original_Pass AND [Email] = @original_Email AND [Dienthoai] = @original_Dienthoai"
            
           OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
          
           
           <DeleteParameters>
                <asp:Parameter Name="original_MaAdmin" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="TenAdmin" Type="String" />
                <asp:Parameter Name="Pass" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Dienthoai" Type="String" />
                
                <asp:Parameter Name="original_MaAdmin" Type="Int32" />
                <asp:Parameter Name="original_TenAdmin" Type="String" />
                <asp:Parameter Name="original_Pass" Type="String" />
                <asp:Parameter Name="original_Email" Type="String" />
                <asp:Parameter Name="original_Dienthoai" Type="String" />
                
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="TenAdmin" Type="String" />
                <asp:Parameter Name="Pass" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Dienthoai" Type="String" />
               
            </InsertParameters>
           
       </asp:SqlDataSource>
        
        
        
        <asp:SqlDataSource ID="SqlDataSource" runat="server" 
           ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
           SelectCommand="SELECT [MaAdmin], [TenAdmin], [Pass], [Email], [Dienthoai] FROM [Admin]">
           
       </asp:SqlDataSource>
       
            
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
        <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
     
        
        <br />
       
        <!-- content end -->
        
    </form>
</body>
</html>
